<template>
     <div class="page add-member" style="height:200px;overflow:scroll">
        <div class="weui-cells weui-cells_radio select-role" >

           <label class="weui-cell weui-check__label" :for="'x'+item.confirm_id" v-for="(index, item) in confirmList" @click="setType(item.confirm_id,item.subject)">
                <div class="weui-cell__bd">
                    <h2>{{item.subject}}</h2>
                </div>
                <div class="weui-cell__ft">
                      <input type="radio" class="weui-check" name="radio1" :id="'x'+item.confirm_id" v-bind:checked="selectedIdentityId == item.confirm_id">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>
        </div>
     <!-- report_status == 1 可点击  report_status == 0 不可点击 -->     
            <!-- 空页面 -->
    <div class="page" v-show="empty">
        <div class="mod-empty">
            <div class="icon icon_1"></div>
            <p class="tip">暂无数据</p>
        </div>

    </div> 
        <div style="margin:80px 0px 0px 0px">
          <div  v-if="selectedIdentityId" class="btn-box bg-color fixed" @click='confirm' :style="isIphoneX?'padding-bottom: 35px;':''"><a href="javascript:;" class="weui-btn weui-btn_primary">一键生成工资单</a></div>
          <div  v-else class="btn-box_default bg-color fixed" :style="isIphoneX?'padding-bottom: 35px;':''"><a href="javascript:;" class="weui-btn ">一键生成工资单</a></div>

        </div>
    </div>  
 <!--    <div class="page__bd" v-show="showMore">
        <div class="weui-loadmore">
           <i class="weui-loading"></i>
           <span class="weui-loadmore__tips">正在加载</span>
        </div>
    </div>  -->
        
</template> 

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'
    import widget from 'gapi/widget.js'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */
     let paremData = []
     let notParemData = []
     let teamId = ''
     let noticeId = ''
     let userId = ''
     let title = ''
     let desc = ''
     let startPage_not= 1
     let offset_not = 20
     let startPage = 1
     let offset = 20
     let canLoadMore = 1
     let status=3
     let filter_no=1
    

     // import Dialog from 'components/Dialog/Dialog'
    /**
     *  组件实例对象
     */
    export default {
        components: {
            // Dialog
        },
        data: function(){
            return{
                empty:false,        //   空页面展示
                showMore:false,    // 已确认公告 , ‘正在加载’ 标示显示  默认不显示  当分页时显示
                confirmList:[],       // 已确认公告列表
                confirmCount:'',   // 已确认总数
                isClick:false,
                recBtn_show:false,
                selectedIdentityId : ''   ,
                order_id:'',
                Height:""
            }
               
        },
        vuex: {
            getters: {

            },
            actions: {

            }

        },  computed: {
            isIphoneX: function(){
                return util.isIphoneX()
            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){ 
              this.projectId = util.getUrddataString('project_id')
              this.teamId = util.getUrddataString('team_id')
              this.user_id = util.getUrddataString('user_id')
              this.isNewCreat= util.getUrddataString('isNewCreat')
              this.empty = false
              this.confirmFn();                
            },

            //选择角色
            setType (typeId,typeName){
                this.selectedIdentityId=typeId
            
                if(this.isClick){
                    return
                }
                this.isClick = true
                let memberList = {
                    id: typeId,
                    name: typeName 
                }} ,
            /*确认*/
            confirmFn (){
                // startPage_not = 1
   
                commonPage.loadPageStatus('loading')
              util.ajax({
                    url:'/confirm/list/status',
                    type:'GET',
                    data:{
                      status_no: status,
                      team_id: this.teamId,
                      project_id: this.projectId,
                      filter_no: filter_no
                    }, 
                    timeout:10000,
                    success:(obj) => {   
                        commonPage.loadPageStatus('loadSuccess')
                        
                        if(obj&&obj.errno == 0){
                            if(obj.data.list.length){                          
                                this.confirmList = obj.data.list
                           
                                this.confirmCount = obj.data.confirmed == 0 ? '' : '(' +obj.data.confirmed+')'
                           
                                this.empty = false
                            }else{
                                
                                this.empty = true
                                canLoadMore = 0 
                          
                            }
                        }else{
                               this.empty = true
                            widget.toast(obj.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        // 无网络的回调
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
        
           
 /*确认收到*/
            confirm (){

                if(this.empty){
                     widget.toast("无数据")
                     return
                }
                    commonPage.loadPageStatus('loading')
                
                util.ajax({
                    url:'/wage/order_user_by_confirm/save',
                    type:'POST',
                    data:{
                        team_id: this.teamId,
                        project_id: this.projectId,
                        confirm_id: this.selectedIdentityId,
                       
                    },
                    timeout:10000,
                    success:(obj) => {
                      
                       commonPage.loadPageStatus('loadSuccess')
                        if(obj&&obj.errno == 0){
                            this.order_id = obj.data.order_id
                       commonPage.goBack(1);
                //              let str = `team_id=${this.teamId}&project_id=${this.projectId}&order_id=${this.order_id}&user_id=${this.user_id}&isNewCreat=${this.isNewCreat}`
                // let encodeStr = encodeURIComponent(str)
                // location.href = `dmsaas://PayListDetail?urdData=${encodeStr}`
                        }else{
                            widget.toast(obj.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                          commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                          commonPage.loadPageStatus('loadSuccess')
                        // 无网络的回调
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            
            /*跳转到个人信息*/
            gotoUserInfo (user_id){
                let str = `tid=${teamId}&pid=${projectId}&uid=${user_id}`
                let encodeStr = encodeURIComponent(str)
                location.href = `dmsaas://ProjectMemberDetail?urdData=${encodeStr}`
            },
        },
        filters: {
            formatDateTime(date){
                return util.formatDate(date);
            }
        },
        created(){ 
            this.init();


        }
    }

</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/notice.css"></style>
<style src="../../static/css/project.css"></style>
<style>

    .mod-tabs{
        position: fixed;
       
    }
     .weui-cells_radio .weui-check:checked + .weui-icon-checked:before {
      display: block;
      content: "";
      width: 18px;
      height: 18px;
      background-image: url(../../static/imgs/single_selected.png);
      background-size: 18px 18px;
      overflow: hidden;
    }
.weui-btn {
    height: 46px;
    line-height: 52px;
    width: 100%;
    font-size: 16px;
    color: #CCCCCC;

}
.weui-btn:after {
  border: none;
}
.weui-btn_primary {
      height: 46px;
    line-height: 52px;
    background-color: white;
    color: #fa0;

}
.weui-btn_primary:not(.weui-btn_disabled):active {
     background-color: white;
  color: #fa0;
}
.btn-box:active{
  background: #f0f0f0!important;
}
.weui-btn_primary:active{
  background: #f0f0f0!important;
}
.weui-cells {
  margin-bottom: this.
}
.btn-box_default.fixed {
  padding: 9px 10px 10px;
  border-top: 1px solid #e6e6e6;
  position: fixed;
  width: 100%;
  box-sizing: border-box;
  left: 0;
  bottom: 0;
  z-index: 99;
}
</style>




